<?php
defined('_JEXEC') or die('Restricted access');
class sanphamHelper
{
	function getAllData($star, $number, $ordering=NULL, $where=NULL)
	{
		if($where){
			$where = "publish=1 AND $where";
		}else{
			$where = 'publish=1';
		}
		
		if($ordering){
			$ordering= "ORDER BY $ordering";
		}else{
			$ordering=' ORDER BY id DESC ';
		}
		$sqlnum="select id from dm_sanpham where $where";
		$sql="select * from dm_sanpham where $where $ordering LIMIT $star, $number";
		$querynum=mysql_query($sqlnum);
		$number= mysql_num_rows($querynum);
		$query=mysql_query($sql);	
		
		$value=array();
		$value['query']=$query;
		$value['number']=$number;
		return  $value;
	}
	
	function getdetail($id)
	{
		$sql="select * from dm_sanpham where publish=1 AND  id=$id";
		$rs=mysql_query($sql);
		$value=mysql_fetch_assoc($rs);
		return  $value;
	}
}